#include "fig_boss_eagle.h"
#include "fighter.h"
#include "fig_bullet.h"
#include "fig_enemybullet_master.h"
#include "fig_player_craft.h"
#include "fig_sounds.h"
#include "fig_boss_attackmove_manager.h"

#include "num/rand.h"
#include "math/facing.h"
#include "dd/dd_man.h"

FIGBossEagle::FIGBossEagle(FIGEnemyCraft::ENEMY_TYPES EnemyType) : 
								FIGEnemyBoss(											
											 EnemyType
											)
								
{
	m_ShootCounter.SetLimit(4.3f);	
	m_SecondaryWeaponCounter.SetLimit(3.0f);
	m_SecondaryWeaponCounter.ForceReady();
}


void			FIGBossEagle::OnShootStyle1()
{
	float	ShootDegree = 45;

	const int ShootCount = 45;
	for(int i = 0; i < ShootCount; i++)
	{
		FIGEnemyBulletMaster::Instance().Shoot(
											this,
											m_Bone.GetPosByWayPoint(0),
											FIGEnemyBulletMaster::BULLET_TYPE_LONG_CYAN,
											FIGBullet::SHOOT_STYLES_SINGLE,
											45.0f + 180.0f,		// degree
											i * 0.1f,
											false,
											NULL,
											false,
											FIGSounds::BOSS_SHOOT
          									);	

		
		FIGEnemyBulletMaster::Instance().Shoot(
											this,
											m_Bone.GetPosByWayPoint(1),
											FIGEnemyBulletMaster::BULLET_TYPE_LONG_CYAN,
											FIGBullet::SHOOT_STYLES_SINGLE,
											-45.0f + 180.0f,		// degree
											i * 0.1f,
											false,
											NULL,
											false,
											FIGSounds::BOSS_SHOOT
          									);	

		FIGEnemyBulletMaster::Instance().Shoot(
											this,
											m_Bone.GetPosByWayPoint(2),
											FIGEnemyBulletMaster::BULLET_TYPE_LONG_RED,
											FIGBullet::SHOOT_STYLES_SINGLE,
											-ShootDegree + 180.0f,		// degree
											i * 0.1f,
											false,
											NULL,
											false,
											FIGSounds::BOSS_SHOOT
          									);	

		
		FIGEnemyBulletMaster::Instance().Shoot(
											this,
											m_Bone.GetPosByWayPoint(3),
											FIGEnemyBulletMaster::BULLET_TYPE_LONG_RED,
											FIGBullet::SHOOT_STYLES_SINGLE,
											ShootDegree + 180.0f,		// degree
											i * 0.1f,
											false,
											NULL,
											false,
											FIGSounds::BOSS_SHOOT
          									);	

		if( i > ShootCount / 3)
		{
			ShootDegree -= ((45.0f/(float)ShootCount) * 3.0f);
			if(ShootDegree < 0)
				ShootDegree = 0;
		}

	}

	
}


void			FIGBossEagle::OnShootStyle2()
{
	if(num::RAND32::Instance().RandInt(0,3) == 0)	
			FIGBossAttackMoveManager::Instance().Start(
									FIGBossAttackMoveManager::ATTACK_MOVEMENT_RIGHT_AND_LEFT, 
									0.0f);

	bool IsPlus = false;
	float ShootDegree = 135.0f + 90.0f;
	float Delay = 0.0f;

	for(int k = 0; k < 8; k++)
	{
		for( int j = 0; j < 3; j++)
		{
			for(int i =2; i < 4; i++)
			{
				FIGEnemyBulletMaster::Instance().Shoot(
													this,
													m_Bone.GetPosByWayPoint(i),
													FIGEnemyBulletMaster::BULLET_TYPE_CIRCLE_DOUBLELAYER,
													FIGBullet::SHOOT_STYLES_SINGLE,
													ShootDegree + 180.0f,		// degree
													Delay,
													false,
													NULL,
													false,
													FIGSounds::BOSS_SHOOT
          											);
				
			}
			
			for(int ii =0; ii < 2; ii++)
			{
				FIGEnemyBulletMaster::Instance().Shoot(
													this,
													m_Bone.GetPosByWayPoint(ii),
													FIGEnemyBulletMaster::BULLET_TYPE_CIRCLE_DOUBLELAYER,
													FIGBullet::SHOOT_STYLES_SINGLE,
													ShootDegree,		// degree
													Delay,
													false,
													NULL,
													false,
													FIGSounds::BOSS_SHOOT
          											);
				
			}

			Delay += 0.1f;

			if(IsPlus)
				ShootDegree += (90.0f / 4.0f);
			else
				ShootDegree -= (90.0f / 4.0f);

		}

		IsPlus = !IsPlus;
	}

	

	
}

void			FIGBossEagle::OnShootStyle3()
{
	if(num::RAND32::Instance().RandInt(0,3) == 0)	
			FIGBossAttackMoveManager::Instance().Start(
			FIGBossAttackMoveManager::ATTACK_MOVEMENT_CIRCLE, 
									0.0f);
	for(int j = 0; j < 6; j++)
	{
		for(int i = 0; i < 6; i++)
		{
			FIGEnemyBulletMaster::Instance().Shoot(
														this,
														m_Bone.GetPosByWayPoint(i),
														FIGEnemyBulletMaster::BULLET_TYPE_LONG_RED,
														FIGBullet::SHOOT_STYLES_DOUBLE,
														0,		// degree
														0.7f * j,
														true,
														NULL,
														false,
														FIGSounds::BOSS_SHOOT
          												);
		}
	}


}


void			FIGBossEagle::OnShootStyle4()
{

	const float SHOOT_DIRS = 8.0f;
	float ExtraDegree = 0;
	float ShootDegree;
	for(int j = 0; j < 8; j++)
	{
		ExtraDegree += (20.0f) ;
		

		for(int i = 0; i < SHOOT_DIRS; i++)
		{
			

			ShootDegree = ((360.0f / SHOOT_DIRS) * i);
			ShootDegree += ExtraDegree;
			FIGEnemyBulletMaster::Instance().Shoot(
														this,
														m_Bone.GetPosByWayPoint(6),
														FIGEnemyBulletMaster::BULLET_TYPE_CIRCLE_GLOW,
														FIGBullet::SHOOT_STYLES_SHAPE_TRIANGLE,
														ShootDegree,		// degree
														0.5f * j,
														false,
														NULL,
														false,
														FIGSounds::BOSS_SHOOT
          												);

			
		
		}
	}
}

void			FIGBossEagle::OnSecondaryWeaponShoot()
{
	

	for(int i = 0; i < 3; i++)
	{
		FIGEnemyBulletMaster::Instance().Shoot(
											this,
											m_Bone.GetPosByWayPoint(4),
											FIGEnemyBulletMaster::BULLET_TYPE_CIRCLE_TRIPPLELAYER,
											FIGBullet::SHOOT_STYLES_SINGLE,
											180.0f,		// degree
											i * 0.2f,
											false,
											NULL,
											false,
											FIGSounds::BOSS_SHOOT
          									);	

		FIGEnemyBulletMaster::Instance().Shoot(
											this,
											m_Bone.GetPosByWayPoint(5),
											FIGEnemyBulletMaster::BULLET_TYPE_CIRCLE_TRIPPLELAYER,
											FIGBullet::SHOOT_STYLES_SINGLE,
											180.0f,		// degree
											i * 0.2f,
											false,
											NULL,
											false,
											FIGSounds::BOSS_SHOOT
          									);	
	}
}












	